﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAL;
using Entities;
using BUS;
using Utility;

public partial class Administrator_doanhnghiep_register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void bt_dangky_Click(object sender, EventArgs e)
    {
        try
        {
            Tbl_doanhnghiep_Entities doanhnghiep = new Tbl_doanhnghiep_Entities();
            doanhnghiep.MaDoanhNghiep = txt_madoanhnghiep.Text;
            doanhnghiep.TenDoanhNghiep = txt_tendoanhnghiep.Text;
            doanhnghiep.DiaChi = txt_diachi.Text;
            doanhnghiep.DienThoai = txt_dienthoai.Text;
            doanhnghiep.WebSite = txt_website.Text;
            doanhnghiep.GioiThieu = FreeTextBox1.Text;
            doanhnghiep.Taikhoan = txt_tentaikhoan.Text;
            doanhnghiep.Matkhau = txt_matkhau1.Text;

            if (FileUpload2.HasFile)
            {
                string filename = DateTime.Now.Ticks.ToString() + "_" + FileUpload2.FileName;
                FileUpload2.SaveAs(Server.MapPath("~/Photos/" + filename));

                System.Drawing.Image img = System.Drawing.Image.FromFile(
                    Server.MapPath("~/Photos/" + filename));

                ImageUtility.MakeThumbnailPhoto(
                    img, 100, 100, Server.MapPath("~/Photos/Thumbs/"), filename);

                doanhnghiep.Map = filename;

            }
            else
            {
                doanhnghiep.Map = "noimages.jpg";
            }
            
            int stt = Tbl_doanhnghiep_BUS.Insert(doanhnghiep);

            
        }
        catch
        {
            Response.Redirect("~/Administrator/doanhnghiep.aspx");
        }
        Response.Redirect(Request.RawUrl);
    }

}
